import 'package:flutter/material.dart';

/// Extension on the [Widget]
extension WidgetExtension on Widget {
  /// JMWidgetExtension: Add double tap.
  ///
  /// Example:
  /// ```dart
  /// Container().onDoubleTap()
  /// ```
  Widget onDoubleTap(Function() function) => GestureDetector(onDoubleTap: function, child: this);

  /// JMWidgetExtension: Add long press.
  ///
  /// Example:
  /// ```dart
  /// Container().onLongPress()
  /// ```
  Widget onLongPress(Function() function) => GestureDetector(onLongPress: function, child: this);

  /// JMWidgetExtension: Add tap.
  ///
  /// Example:
  /// ```dart
  /// Container().onTap()
  /// ```
  Widget onTap(Function() function) => GestureDetector(onTap: function, child: this);

  /// JMWidgetExtension: Add tap with inkwell noSplash.
  ///
  /// Example:
  /// ```dart
  /// Container().onInkwellTap()
  /// ```
  Widget onInkwellTap(Function() function) {
    return InkWell(
      splashFactory: NoSplash.splashFactory,
      onTap: function,
      child: this,
    );
  }
}
